package com.itstyle.seckill.topic.ai;

/**
 * @Auther: liuwenxiang
 * @Date: 2019/11/20 11:38
 * @Description: 顺序查找（无序）
 */
public class Sequential_Search {

    public static int seq_search(int[] arr,int num){
        for(int i=0;i<arr.length;i++){
            if(arr[i]==num){
                return i;
            }
        }
        return 0;
    }


    public static int seq_search1(int[] arr,int num){
        int i=arr.length;
        while(arr[i]!=num){
            i--;
        }
        return 0;
    }

    public static void main(String[] args) {
        int[] arr = {0,45,68,32,15};
        System.out.println(seq_search(arr,68));
    }

}
